package org.xiaojl.modules.sys.service.impl;

import java.util.List;

import org.springframework.stereotype.Service;
import org.xiaojl.config.easyui.EasyUITree;
import org.xiaojl.config.easyui.EasyuiUtil;
import org.xiaojl.modules.sys.entity.Organization;
import org.xiaojl.modules.sys.mapper.OrganizationMapper;
import org.xiaojl.modules.sys.service.OrganizationService;
import org.xiaojl.utils.ToolUtil;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;

/**
 * <p>
 * 组织机构 服务实现类
 * </p>
 *
 * @author xiaojl
 * @since 2017-09-19
 */
@Service
public class OrganizationServiceImpl extends ServiceImpl<OrganizationMapper, Organization> implements OrganizationService {

	@Override
	public List<EasyUITree> selectTree() {
		List<Organization> list = this.selectList(null);
		
		return EasyuiUtil.organization2EasyUITree(list);
	}

	@Override
	public void deleteWithCascade(Organization entity) {
		if(ToolUtil.isNotEmpty(entity)){
			this.delete(new EntityWrapper<Organization>().eq("pid",entity.getId()));
			this.deleteById(entity.getId());
		}
	}
	
}
